var xiaoming = {
    name: '小明',
    age: 14,
    gender: true,
    height: 1.65,
    grade: null,
    'middle-school': '\"W3C\" Middle School',
    skills: ['JavaScript', 'Java', 'Python', 'Lisp']
};

var s = JSON.stringify(xiaoming);
var sf = JSON.stringify(xiaoming, null, ' ');
console.log(s);
console.log(sf);

function convert(key, value)
{
    if(typeof value == 'string')
        return value.toUpperCase();
    return value;
}

var su = JSON.stringify(xiaoming, convert, ' ');
console.log(su);


var xiaoming = {
    name: '小明',
    age: 14,
    gender: true,
    height: 1.65,
    grade: null,
    'middle-school': '\"W3C\" Middle School',
    skills: ['JavaScript', 'Java', 'Python', 'Lisp'],
    toJSON: function () {
        return { // 只输出name和age，并且改变了key：
            'Name': this.name,
            'Age': this.age
        };
    }
};


var tos = JSON.stringify(xiaoming);
console.log(tos);

var obj = JSON.parse('{"name":"小明","age":14}', function (key, value) {
    if (key === 'name') {
        return value + '同学';
    }
    return value;
});

console.log(JSON.stringify(obj)); // {name: '小明同学', age: 14}

var url = 'https://api.openweathermap.org/data/2.5/forecast?q=Beijing,cn&appid=800f49846586c3ba6e7052cfc89af16c';
$.getJSON(url, function (data) 
{
    var info = 
    {
        city:    data.city.name,
        weather: data.list[0].weather[0].main,
        time:    data.list[0].dt_txt
    };
    alert(JSON.stringify(info, null, '  '));
});